From: Florian Müllner Date: Wed, 3 Aug 2022 21:24:53 +0000 (+0200) Subject: status/network: Override activate() for wireless X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~461^2^2~43 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=791c65a5f943ac9e329ef67a9fcb1b11502f4946;p=gnome-shell.git status/network: Override activate() for wireless Wireless items represent a single adapter, but wireless connectivity is controlled globally under NetworkManager. So instead of delegating activation to items, bind the :checked property to the global :wireless-enabled property and toggle it on activate. As any wireless devices will change their state to UNAVAILABLE when wireless is disabled, don't remove corresponding items in that case to keep the section visible. We don't want to hide the button to turn Wi-Fi back on when toggled off :-) Part-of: --- diff --git a/js/ui/status/network.js b/js/ui/status/network.js index 431ca5ad6..28a5cfa0f 100644 --- a/js/ui/status/network.js +++ b/js/ui/status/network.js @@ -1699,9 +1699,32 @@ class NMWirelessSection extends NMDeviceSection { 'gnome-wifi-panel.desktop'); } + setClient(client) { + super.setClient(client); + + this._client?.bind_property('wireless-enabled', + this, 'checked', + GObject.BindingFlags.SYNC_CREATE); + } + + activate() { + this._client.wireless_enabled = !this._client.wireless_enabled; + } + _createDeviceMenuItem(device) { return new NMWirelessDeviceItem(this._client, device); } + + _updateChecked() { + // handled via a property binding + } + + _shouldShowDevice(device) { + // don't disappear if wireless-enabled is false + if (device.state === NM.DeviceState.UNAVAILABLE) + return true; + return super._shouldShowDevice(device); + } }); const NMWiredSection = GObject.registerClass(